package pixelwaks.ctrl.impl;

import java.util.Random;

import common.ctrl.IObserver;
import common.gui.IViewable;

import pixelwaks.core.impl.Game;

public class WindCtrl implements IObserver {

	private IViewable iv;
	
	public WindCtrl() {
		setNewWind();
	}
	
	@Override
	public void addView(IViewable iv) {
		this.iv = iv;
	}
	
	public void updateWind() {		
		setNewWind();
		iv.updateView(null);
	}
	
	private void setNewWind() {		
		Random random = new Random();
		int direction = random.nextInt(2);
		double windSpeed = random.nextDouble() * Game.getInstance().getWind().getLevel();
		Game.getInstance().getWind().setDirection(direction);
		Game.getInstance().getWind().setWindSpeed(windSpeed);
	}
}
